<template>
	<div>
	<Layout :style="{marginLeft: '90px'}">
        <Header :style="{background: '#fff', boxShadow: '0 2px 3px 2px rgba(0,0,0,.1)'}">
             <div style="display:inline-block;float:left;">    
                <h2 class="inline-block">{{userName}}</h2>
                <Tag checkable color="error">试用期</Tag>
                <Tag color="default">SVIP</Tag>
                <Tag type="border"  color="primary">有赞担保</Tag>
            </div>
            <div style="display:inline-block;float:right;">
                <el-dropdown>
                    <div>
                        <Icon type="ios-contact" size='20'/>
                        <span style="margin:0 3px 0 3px">1350000000</span>
                        <Icon type="ios-arrow-forward" size='20'/>
                    </div>
                    <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item >切换账户<Icon type="ios-repeat" size="19"style="margin-left: 40px;"/></el-dropdown-item>
                    <el-dropdown-item divided>邀请客户<Icon type="ios-contacts-outline" size="19"style="margin-left: 40px;"/></el-dropdown-item>
                    <el-dropdown-item divided>个人设置<Icon type="ios-build-outline" size="19"style="margin-left: 40px;"/></el-dropdown-item>
                    <el-dropdown-item divided @click.native='Logout'>退出登录<Icon type="ios-power-outline" size="19"style="margin-left: 40px;"/></el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </Header>
        
        <Content :style="{padding: '0 16px 16px'}">
        	<Card style="margin-top:20px ;">
                <div style="min-height: 300px">
		        <el-row :gutter="20">
		            <el-col :span="8">
		                <el-card shadow="hover" class="mgb20" style="height:252px;">
		                    <div class="user-info">
		                        <img src="../../../static/user.jpg" class="user-avator" alt="">
		                        <div class="user-info-cont">
		                            <div class="user-info-name">{{name}}</div>
		                            <div>{{role}}</div>
		                        </div>
		                    </div>
		                    <div class="user-info-list">上次登录时间：<span>2018-10-01</span></div>
		                    <div class="user-info-list">上次登录地点：<span>龙神山</span></div>
		                </el-card>
		                <el-card shadow="hover" style="height:252px;">
		                    <div slot="header" class="clearfix">
		                        <span>状态详情</span>
		                    </div>
		                                 <span>状态一</span>                                 
		                    <el-progress :percentage="71.3" color="#42b983"></el-progress>
		                                 <span>状态二</span>                                
		                    <el-progress :percentage="24.1" color="#f1e05a"></el-progress>
		                                 <span>状态三</span>                                   
		                    <el-progress :percentage="3.7"></el-progress>
		                                 <span>状态四</span>                                  
		                    <el-progress :percentage="0.9" color="#f56c6c"></el-progress>
		                </el-card>
		            </el-col>
		            <el-col :span="16">
		                <el-row :gutter="20" class="mgb20">
		                    <el-col :span="8">
		                        <el-card shadow="hover" :body-style="{padding: '0px'}">
		                            <div class="grid-content grid-con-1">
		                                <Icon type="ios-contact-outline" class="grid-con-icon"/>
		                                <div class="grid-cont-right">
		                                    <div class="grid-num">432434</div>
		                                    <div>用户访问量</div>
		                                </div>
		                            </div>
		                        </el-card>
		                    </el-col>
		                    <el-col :span="8">
		                        <el-card shadow="hover" :body-style="{padding: '0px'}">
		                            <div class="grid-content grid-con-2">
		                                <!--<i class="el-icon-lx-notice grid-con-icon"></i>-->
		                                <Icon type="ios-notifications" class="grid-con-icon"/>
		                                <div class="grid-cont-right">
		                                    <div class="grid-num">321</div>
		                                    <div>系统消息</div>
		                                </div>
		                            </div>
		                        </el-card>
		                    </el-col>
		                    <el-col :span="8">
		                        <el-card shadow="hover" :body-style="{padding: '0px'}">
		                            <div class="grid-content grid-con-3">
		                                <Icon type="ios-stats" class="grid-con-icon"/>
		                                <div class="grid-cont-right">
		                                    <div class="grid-num">5600</div>
		                                    <div>解决Bug数</div>
		                                </div>
		                            </div>
		                        </el-card>
		                    </el-col>
		                </el-row>
		                <el-card shadow="hover" style="height:403px;">
		                    <div slot="header" class="clearfix">
		                        <span>待办事项</span>
		                        <el-button style="float: right; padding: 3px 0" type="text">添加</el-button>
		                    </div>
		                    <el-table :data="todoList" :show-header="false" height="304" style="width: 100%;font-size:14px;">
		                        <el-table-column width="40">
		                            <template slot-scope="scope">
		                                <el-checkbox v-model="scope.row.status"></el-checkbox>
		                            </template>
		                        </el-table-column>
		                        <el-table-column>
		                            <template slot-scope="scope">
		                                <div class="todo-item" :class="{'todo-item-del': scope.row.status}">{{scope.row.title}}</div>
		                            </template>
		                        </el-table-column>
		                        <el-table-column width="60">
		                            <template slot-scope="scope">
		                                <i class="el-icon-edit"></i>
		                                <i class="el-icon-delete"></i>
		                            </template>
		                        </el-table-column>
		                    </el-table>
		                </el-card>
		            </el-col>
		        </el-row>
                </div>
            </Card>
            <Card style="margin-top:20px ;">
                <div style="min-height: 300px">
                    <div id="myChart" :style="{width: '100%', height:'400px'}"></div>  
                </div>
            </Card>
            <Card style="margin-top:20px;">
                <div style=" min-height: 200px;">
                    <Header :style="{background: '#fff',padding:0}">
                        <h3 style="text-align:left">重要事项</h3>
                    </Header>  
                	<el-row :gutter="20">
                        <el-col :span="20"><div class="grid-content bg-purple">订单相关</div></el-col>
                        <el-col :span="4"><div class="grid-content bg-purple">通知消息</div></el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8"><div class="grid-content bg-purple greyInfo">代发货订单:0</div></el-col>
                        <el-col :span="12"><div class="grid-content bg-purple greyInfo">待处理退款:0</div></el-col>
                        <el-col :span="4"><div class="grid-content bg-purple greyInfo">未读客户消息:0</div></el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="20"><div class="grid-content bg-purple">订单相关</div></el-col>
                        <el-col :span="4"><div class="grid-content bg-purple">通知消息</div></el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8"><div class="grid-content bg-purple greyInfo">代发货订单:0</div></el-col>
                        <el-col :span="8"><div class="grid-content bg-purple greyInfo">待处理退款:0</div></el-col>
                        <el-col :span="4"><div class="grid-content bg-purple greyInfo">待处理退款:<span style="color:red">12</span></div></el-col>
                        <el-col :span="4"><div class="grid-content bg-purple greyInfo">未读客户消息:0</div></el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8"><div class="grid-content bg-purple greyInfo">代发货订单:0</div></el-col>
                        <el-col :span="8"><div class="grid-content bg-purple greyInfo">待处理退款:0</div></el-col>
                        <el-col :span="8"><div class="grid-content bg-purple greyInfo">未读客户消息:0</div></el-col>
                    </el-row>
                </div>
            </Card>
            
            <Card style="margin-top:20px ;">
                <div style="min-height: 200px;background-color: #aaa">
                	<div v-for="item in List">
                		<img :src="item.imageUrl"/>
                	</div>
                </div>
            </Card>
        </Content>
    </Layout>
	</div>
</template>

<script>
	import axios from './../../util/js/http.js'
	export default{
		data () {
            return {
            	List:[],
            	userName:'一朵菊花那样红',
                formItem: {
                    input: '',
                    select: '',
                    radio: 'male',
                    checkbox: [],
                    switch: true,
                    date: '',
                    time: '',
                    slider: [20, 50],
                    textarea: ''
                },
//              name: localStorage.getItem('ms_username'),
                name:'admin',
                todoList: [{
                        title: '今天要修复30个bug',
                        status: false,
                    },
                    {
                        title: '今天要修复50个bug',
                        status: false,
                    },
                    {
                        title: '今天要写5600行代码加几个bug吧',
                        status: false,
                    }, {
                        title: '今天要修复145个bug',
                        status: false,
                    },
                    {
                        title: '今天要修复34个bug',
                        status: true,
                    },
                    {
                        title: '今天要写100行代码加几个bug吧',
                        status: true,
                    }
                ],
                data: [{
                        name: '2018/09/04',
                        value: 1083
                    },
                    {
                        name: '2018/09/05',
                        value: 941
                    },
                    {
                        name: '2018/09/06',
                        value: 1139
                    },
                    {
                        name: '2018/09/07',
                        value: 816
                    },
                    {
                        name: '2018/09/08',
                        value: 327
                    },
                    {
                        name: '2018/09/09',
                        value: 228
                    },
                    {
                        name: '2018/09/10',
                        value: 1065
                    }
                ],
                options: {
                    title: '最近七天每天的用户访问量',
                    showValue: false,
                    fillColor: 'rgb(45, 140, 240)',
                    bottomPadding: 30,
                    topPadding: 30
                },
                options2: {
                    title: '最近七天用户访问趋势',
                    fillColor: '#FC6FA1',
                    axisColor: '#008ACD',
                    contentColor: '#EEEEEE',
                    bgColor: '#F5F8FD',
                    bottomPadding: 30,
                    topPadding: 30
                }
            }
       },
		
		computed: {
        role() {
            return this.name === 'admin' ? '超级管理员' : '普通用户';
         }
        },
		
	   created(){
         this.setNewsApi()
         this.setNews()
       },
       mounted(){
        this.drawLine()
       },
		methods:{
            Logout(){
                console.log('退出')
                sessionStorage.removeItem('token')
        		this.$router.push('/')
        	},
			setNewsApi() {
			      axios.getHttp('/news/index', 'type=top&key=123456')
			      .then(res => {
			        console.log(res);
			        this.List = res.data;
			      });
			    },
			setNews() {
			      axios.getHttp('/news/play', 'type=top&key=123456')
			      .then(res => {
			        console.log(res);
			        this.List = res.data;
			      });
			    },
            drawLine(){
                    // 基于准备好的dom，初始化echarts实例
                    let myChart = this.$echarts.init(document.getElementById('myChart'))
                    // 绘制图表
                    myChart.setOption({
                        title: {
                            text: '2018年数据表'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
                        },
                        // grid: {
                        //     left: '3%',
                        //     right: '4%',
                        //     bottom: '3%',
                        //     containLabel: true
                        // },
                        toolbox: {
                            feature: {
                                saveAsImage: {}
                            }
                        },
                        xAxis: {//x轴
                                type: 'category',
                                boundaryGap: false,
                                data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
                                splitLine: {show: false},//去除网格分割线
                                //splitArea: {show: true},//保留网格区域
                                axisLine: {//坐标线
                                    lineStyle: {
                                        type: 'solid',
                                        color: '#FFFFFF',//轴线的颜色
                                        width:'1'//坐标线的宽度
                                    }
                                },
                                axisTick: {//刻度
                                    show: false//不显示刻度线
                                },
                                axisLabel: {
                                    textStyle: {
                                        color: '#878787',//坐标值的具体的颜色
                                    }
                                },
                                splitLine: {
                                    show: false//去掉分割线
                                },
                            },
                            backgroundColor: '#fff',//图得背景色
                            yAxis: {
                                name: '单位：次',//轴的名字，默认位置在y轴上方显示
                               
                                type: 'value',
                                axisLine: {//线
                                    show: false
                                },
                                axisTick: {//刻度
                                    show: false
                                },
                                axisLabel: {
                                    textStyle: {
                                        color: '#878787',//坐标值得具体的颜色
                                    }
                                },
                                 minInterval: '200',//标值的最小间隔
                                splitLine: {
                                    lineStyle: {
                                        type:'dashed',
                                        color: ['#C1C1C1'],//分割线的颜色
                                    }
                                }
                            },

                        series: [
                            {
                                name:'邮件营销',
                                type:'line',
                                stack: '总量',
                                data:[120, 132, 101, 134, 90, 230, 210, 134, 90, 230, 210]
                            },
                            {
                                name:'联盟广告',
                                type:'line',
                                stack: '总量',
                                data:[120, 132, 101, 134, 90, 230, 210, 134, 90, 230, 210]
                            },
                            {
                                name:'视频广告',
                                type:'line',
                                stack: '总量',
                                data:[120, 132, 101, 134, 90, 230, 210, 134, 90, 230, 210]
                            },
                            {
                                name:'直接访问',
                                type:'line',
                                stack: '总量',
                                data:[120, 132, 101, 134, 90, 230, 210, 134, 90, 230, 210]
                            },
                            {
                                name:'搜索引擎',
                                type:'line',
                                stack: '总量',
                                data:[120, 132, 101, 134, 90, 230, 210, 134, 90, 230, 210]
                            }
                        ]
                    });
                }
		},
	 components:{
	 	
	 }
	}
</script>

<style scoped>
    .inline-block{
        display: inline-block;
    }
    .userInfo{
        text-align: right;
    }
    
    .greyInfo{
        color: #999999;
    }
	.el-row {
        margin-bottom: 20px;
    }

    .grid-content {
        display: flex;
        align-items: center;
        min-height: 21px;
    }

    .grid-cont-right {
        flex: 1;
        text-align: center;
        font-size: 14px;
        color: #999;
    }

    .grid-num {
        font-size: 30px;
        font-weight: bold;
    }

    .grid-con-icon {
        font-size: 50px;
        width: 100px;
        height: 100px;
        text-align: center;
        line-height: 100px;
        color: #fff;
    }

    .grid-con-1 .grid-con-icon {
        background: rgb(45, 140, 240);
    }

    .grid-con-1 .grid-num {
        color: rgb(45, 140, 240);
    }

    .grid-con-2 .grid-con-icon {
        background: rgb(100, 213, 114);
    }

    .grid-con-2 .grid-num {
        color: rgb(45, 140, 240);
    }

    .grid-con-3 .grid-con-icon {
        background: rgb(242, 94, 67);
    }

    .grid-con-3 .grid-num {
        color: rgb(242, 94, 67);
    }

    .user-info {
        display: flex;
        align-items: center;
        padding-bottom: 20px;
        border-bottom: 2px solid #ccc;
        margin-bottom: 20px;
    }

    .user-avator {
        width: 120px;
        height: 120px;
        border-radius: 50%;
    }

    .user-info-cont {
        padding-left: 50px;
        flex: 1;
        font-size: 14px;
        color: #999;
    }

    .user-info-cont div:first-child {
        font-size: 30px;
        color: #222;
    }

    .user-info-list {
        font-size: 14px;
        color: #999;
        line-height: 25px;
    }

    .user-info-list span {
        margin-left: 50px;
    }

    .mgb20 {
        margin-bottom: 20px;
    }

    .todo-item {
        font-size: 14px;
    }

    .todo-item-del {
        text-decoration: line-through;
        color: #999;
    }

    .schart {
        width: 100%;
        height: 300px;
    }
</style>